/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.service.processor.register;

import cn.hutool.core.util.ObjectUtil;
import info.peigen.hotpot.business.customer.core.domain.Customer;
import info.peigen.hotpot.business.customer.core.domain.action.CustomerConverter;
import info.peigen.hotpot.business.customer.core.service.processor.base.AbstractCustomerServiceProcessor;
import info.peigen.hotpot.business.customer.facade.info.CustomerInfo;
import info.peigen.hotpot.business.customer.facade.result.register.CustomerRegisterResult;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import org.noear.solon.annotation.Component;

/**
 * <b>(CustomerRegisterResultProcessor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/8/30
 */
@SuppressWarnings("rawtypes")
@Component
public class CustomerRegisterResultProcessor extends AbstractCustomerServiceProcessor implements Processor {

    @Override
    public Integer level() {
        return 99;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {

        if (ObjectUtil.isNotEmpty(serviceContext.getDomain())) {
            Customer     customer     = (Customer) serviceContext.getDomain();
            CustomerInfo customerInfo = CustomerConverter.convertCustomerInfo(customer);
            ((CustomerRegisterResult) serviceContext.getResult()).fromSuccess(customerInfo);
        }
    }
}
